package com.woniuxy.listener;

import com.rabbitmq.client.Channel;
import com.woniuxy.entity.Mail;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;


/**
 * @Author: 马宇航
 * @Description: 拒绝消息的消费者
 * @DateTime: 22/10/20/0020 14:47
 * @Component: 成都蜗牛学苑
 **/
//@Component
public class NackMessageListener {
    @RabbitListener(queues = {"forDeathQueue2"})
    public void rejectMessage(Mail mail, Channel channel, Message message) throws IOException {
        channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,false);
        System.out.println("正常消费者拒绝消费："+mail);

    }
}
